# -*- coding: utf-8 -*-
"""
Created on Sat Aug  7 20:46:01 2021

@author: chibi
"""

from PIL import Image
im = Image.open("test.png")

print(im.format, im.size, im.mode)


w,h  = im.size

#print(im.getpixel((0,0)))
#print(im.getpixel((0,1)))
#print(im.getpixel((1,0)))
#print(im.getpixel((1,0)))

text = 'S,\n'

for y in range(0,h):
    for x in range(0,w):
        if x < w :
            if im.getpixel((x,y)) == 0:
                bit = '0'
            else:
                bit = '1'
            text += bit
            if x == w-1:
                text += ",\n"
text += 'E,\n'
print (text)


temp = 'temp.txt'

with open (temp,'a') as f :
    f.write(text)
        